import { CaptchaImageResponse } from '@/core/captcha/types/model/response/CaptchaImageResponse'
import promiseUtils from '@/core/utils/promiseUtils'
import captchaImageServerApi from '@/core/captcha/serverapi/captchaImageServerApi'
import useAppTokenInfoStore from '@/core/application/store/useAppTokenInfoStore'
import CaptchaConstants from '@/core/captcha/constants/CaptchaConstants'

class CaptchaImageService {
	createBase64ByLogin = (): Promise<CaptchaImageResponse> => {
		const appToken = useAppTokenInfoStore.getState().accessToken
		return promiseUtils.ofResponse(captchaImageServerApi.createBase64ByAppKey(appToken, CaptchaConstants.APP_KEY_LOGIN)).check()
	}
}

export default new CaptchaImageService()
